#ifdef LOSCFG_INOTIFY
#ifndef _INOTIFY_H_
#define _INOTIFY_H_

#include "fs/file.h"
#include "proc_fs.h"
#include "syscall.h"
#include "vnode.h"

#define IN_ACCESS        0x00000001
#define IN_MODIFY        0x00000002
#define IN_CLOSE_WRITE   0x00000008
#define IN_CLOSE_NOWRITE 0x00000010
#define IN_CLOSE         (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)
#define IN_OPEN          0x00000020
#define IN_CREATE        0x00000100
#define IN_DELETE        0x00000200

#define ALL_INOTIFY_BITS (IN_ACCESS | IN_MODIFY | IN_CREATE | IN_DELETE | IN_OPEN | IN_CLOSE)

#define MAX_SUBJECT_EVENT_NUM 1000
#define MAX_OBSERVER_WATCH_NUM 1000

void ProcInotifyInit(void);
int DoInotifyInit(void);
int DoInotifyAddWatch(int fd, const char *filePath, uint32_t eventType);
int DoInotifyRmWatch(int fd, int wd);
int DoInotifyRead(struct Vnode* observerVnode, char *buf, uint32_t bufSize);
int DoInotifyWrite(struct Vnode* observerVnode, struct Vnode *subjectVnode, const char *filePath, uint32_t eventType);
int DoInotifyWriteHead(struct Vnode* observerVnode, struct Vnode *subjectVnode,
    const char *filePath, uint32_t eventType);
int DoInotifyWriteNotHead(struct Vnode* observerVnode, struct Vnode *subjectVnode,
    const char *filePath, uint32_t eventType);
int DoInotifyWriteCheckSize(struct Vnode* observerVnode, struct Vnode *subjectVnode);
int RecordInfoToObserver(const char *filePath, uint32_t eventType);
int InotifyWriteEvent(const char *filePath, int eventType);
int InotifyUpdateWatch(struct Vnode *observerVnode, struct Vnode *subjectVnode, uint32_t eventType);
int InotifyRmWatch(struct Vnode *observerVnode, struct Vnode *subjectVnode, uint32_t eventType);
int InotifyVnodeFree(struct Vnode *vnode);
int InotifyAddWatchToObserver(struct Vnode *observerVnode, const char *filePath, uint32_t eventType);
int InotifyAddWatchToObserverHead(struct Vnode *observerVnode, const char *filePath, uint32_t eventType);
int InotifyAddWatchToObserverNotHead(struct Vnode *observerVnode, const char *filePath, uint32_t eventType);
int InotifyAddWatchToObserverCheckSize(struct Vnode *observerVnode);
int InotifyRmWatchFromObserver(struct Vnode *observerVnode, int wd);
struct WatchInfo* InotifyGetWatchFromObserver(struct Vnode *observerVnode, int wd);

#endif /* !_INOTIFY_H_ */
#endif